package o;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBar.c;
import androidx.appcompat.widget.ActionBarContainer;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionBarOverlayLayout;
import androidx.appcompat.widget.ActionBarOverlayLayout.a;
import androidx.appcompat.widget.ScrollingTabContainerView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.ViewCompat;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import o.ah.g;
import o.bd.e;

@RestrictTo({d.LIBRARY_GROUP})
public class aj extends ActionBar implements a {
    private static final Interpolator ʽॱ = new DecelerateInterpolator();
    static final /* synthetic */ boolean ॱᐝ = (!aj.class.desiredAssertionStatus());
    private static final Interpolator ᐝॱ = new AccelerateInterpolator();
    aw ʻ;
    final ib ʻॱ = new id(this) {
        final /* synthetic */ aj ˎ;

        {
            this.ˎ = r1;
        }

        public void ˎ(View view) {
            if (this.ˎ.ˊॱ && this.ˎ.ʽ != null) {
                this.ˎ.ʽ.setTranslationY(0.0f);
                this.ˎ.ˏ.setTranslationY(0.0f);
            }
            this.ˎ.ˏ.setVisibility(8);
            this.ˎ.ˏ.setTransitioning(false);
            this.ˎ.ͺ = null;
            this.ˎ.ॱॱ();
            if (this.ˎ.ˋ != null) {
                ViewCompat.ᐝॱ(this.ˎ.ˋ);
            }
        }
    };
    b ʼ;
    private Context ʼॱ;
    View ʽ;
    private ArrayList<Object> ʾ = new ArrayList();
    private Dialog ʿ;
    private Activity ˈ;
    private boolean ˉ;
    ck ˊ;
    private int ˊˊ = -1;
    private boolean ˊˋ;
    boolean ˊॱ = true;
    private ArrayList<c> ˊᐝ = new ArrayList();
    ActionBarOverlayLayout ˋ;
    private boolean ˋˊ;
    private boolean ˋˋ;
    boolean ˋॱ;
    private boolean ˋᐝ = true;
    private int ˍ = 0;
    ActionBarContextView ˎ;
    private boolean ˎˎ;
    ActionBarContainer ˏ;
    boolean ˏॱ;
    bb ͺ;
    Context ॱ;
    boolean ॱˊ;
    final ib ॱˋ = new id(this) {
        final /* synthetic */ aj ˏ;

        {
            this.ˏ = r1;
        }

        public void ˎ(View view) {
            this.ˏ.ͺ = null;
            this.ˏ.ˏ.requestLayout();
        }
    };
    final ih ॱˎ = new ih(this) {
        final /* synthetic */ aj ˎ;

        {
            this.ˎ = r1;
        }

        public void ˏ(View view) {
            ((View) this.ˎ.ˏ.getParent()).invalidate();
        }
    };
    aw.c ॱॱ;
    ScrollingTabContainerView ᐝ;

    @RestrictTo({d.LIBRARY_GROUP})
    public class b extends aw implements e {
        private final Context ˊ;
        final /* synthetic */ aj ˋ;
        private WeakReference<View> ˎ;
        private final bd ˏ;
        private aw.c ॱ;

        public b(aj ajVar, Context context, aw.c cVar) {
            this.ˋ = ajVar;
            this.ˊ = context;
            this.ॱ = cVar;
            this.ˏ = new bd(context).ॱ(1);
            this.ˏ.ॱ((e) this);
        }

        public MenuInflater ˋ() {
            return new az(this.ˊ);
        }

        public Menu ˏ() {
            return this.ˏ;
        }

        public void ॱ() {
            if (this.ˋ.ʼ == this) {
                if (aj.ॱ(this.ˋ.ॱˊ, this.ˋ.ˋॱ, false)) {
                    this.ॱ.ˎ(this);
                } else {
                    this.ˋ.ʻ = this;
                    this.ˋ.ॱॱ = this.ॱ;
                }
                this.ॱ = null;
                this.ˋ.ʽ(false);
                this.ˋ.ˎ.ˏ();
                this.ˋ.ˊ.ˏ().sendAccessibilityEvent(32);
                this.ˋ.ˋ.setHideOnContentScrollEnabled(this.ˋ.ˏॱ);
                this.ˋ.ʼ = null;
            }
        }

        public void ˎ() {
            if (this.ˋ.ʼ == this) {
                this.ˏ.ॱॱ();
                try {
                    this.ॱ.ˎ((aw) this, this.ˏ);
                } finally {
                    this.ˏ.ʼ();
                }
            }
        }

        public boolean ˊ() {
            this.ˏ.ॱॱ();
            try {
                boolean ˋ = this.ॱ.ˋ(this, this.ˏ);
                return ˋ;
            } finally {
                this.ˏ.ʼ();
            }
        }

        public void ˎ(View view) {
            this.ˋ.ˎ.setCustomView(view);
            this.ˎ = new WeakReference(view);
        }

        public void ˏ(CharSequence charSequence) {
            this.ˋ.ˎ.setSubtitle(charSequence);
        }

        public void ˋ(CharSequence charSequence) {
            this.ˋ.ˎ.setTitle(charSequence);
        }

        public void ॱ(int i) {
            ˋ(this.ˋ.ॱ.getResources().getString(i));
        }

        public void ˊ(int i) {
            ˏ(this.ˋ.ॱ.getResources().getString(i));
        }

        public CharSequence ʽ() {
            return this.ˋ.ˎ.ˋ();
        }

        public CharSequence ॱॱ() {
            return this.ˋ.ˎ.ॱ();
        }

        public void ˋ(boolean z) {
            super.ˋ(z);
            this.ˋ.ˎ.setTitleOptional(z);
        }

        public boolean ʻ() {
            return this.ˋ.ˎ.ʻ();
        }

        public View ᐝ() {
            return this.ˎ != null ? (View) this.ˎ.get() : null;
        }

        public boolean ॱ(bd bdVar, MenuItem menuItem) {
            if (this.ॱ != null) {
                return this.ॱ.ˎ((aw) this, menuItem);
            }
            return false;
        }

        public void ˎ(bd bdVar) {
            if (this.ॱ != null) {
                ˎ();
                this.ˋ.ˎ.ˎ();
            }
        }
    }

    public aj(Activity activity, boolean z) {
        this.ˈ = activity;
        View decorView = activity.getWindow().getDecorView();
        ˎ(decorView);
        if (!z) {
            this.ʽ = decorView.findViewById(16908290);
        }
    }

    public aj(Dialog dialog) {
        this.ʿ = dialog;
        ˎ(dialog.getWindow().getDecorView());
    }

    private void ˎ(View view) {
        this.ˋ = (ActionBarOverlayLayout) view.findViewById(ah$i.ᐝॱ);
        if (this.ˋ != null) {
            this.ˋ.setActionBarVisibilityCallback(this);
        }
        this.ˊ = ˊ(view.findViewById(ah$i.ˋ));
        this.ˎ = (ActionBarContextView) view.findViewById(ah$i.ᐝ);
        this.ˏ = (ActionBarContainer) view.findViewById(ah$i.ॱ);
        if (this.ˊ == null || this.ˎ == null || this.ˏ == null) {
            throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + "with a compatible window decor layout");
        }
        this.ॱ = this.ˊ.ˎ();
        boolean z = (this.ˊ.ˋॱ() & 4) != 0;
        if (z) {
            this.ˊˋ = true;
        }
        au ˏ = au.ˏ(this.ॱ);
        if (ˏ.ᐝ() || z) {
            z = true;
        } else {
            z = false;
        }
        ˊ(z);
        ˏॱ(ˏ.ˋ());
        TypedArray obtainStyledAttributes = this.ॱ.obtainStyledAttributes(null, g.ˏ, ah.c.ॱ, 0);
        if (obtainStyledAttributes.getBoolean(g.ˋॱ, false)) {
            ˏ(true);
        }
        int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(g.ॱˎ, 0);
        if (dimensionPixelSize != 0) {
            ॱ((float) dimensionPixelSize);
        }
        obtainStyledAttributes.recycle();
    }

    private ck ˊ(View view) {
        if (view instanceof ck) {
            return (ck) view;
        }
        if (view instanceof Toolbar) {
            return ((Toolbar) view).ˋˊ();
        }
        throw new IllegalStateException("Can't make a decor toolbar out of " + (view != null ? view.getClass().getSimpleName() : HwAccountConstants.NULL));
    }

    public void ॱ(float f) {
        ViewCompat.ˋ(this.ˏ, f);
    }

    public void ˎ(Configuration configuration) {
        ˏॱ(au.ˏ(this.ॱ).ˋ());
    }

    private void ˏॱ(boolean z) {
        boolean z2;
        boolean z3;
        boolean z4 = true;
        this.ˉ = z;
        if (this.ˉ) {
            this.ˏ.setTabContainer(null);
            this.ˊ.ˊ(this.ᐝ);
        } else {
            this.ˊ.ˊ(null);
            this.ˏ.setTabContainer(this.ᐝ);
        }
        if (ʼ() == 2) {
            z2 = true;
        } else {
            z2 = false;
        }
        if (this.ᐝ != null) {
            if (z2) {
                this.ᐝ.setVisibility(0);
                if (this.ˋ != null) {
                    ViewCompat.ᐝॱ(this.ˋ);
                }
            } else {
                this.ᐝ.setVisibility(8);
            }
        }
        ck ckVar = this.ˊ;
        if (this.ˉ || !z2) {
            z3 = false;
        } else {
            z3 = true;
        }
        ckVar.ˊ(z3);
        ActionBarOverlayLayout actionBarOverlayLayout = this.ˋ;
        if (this.ˉ || !z2) {
            z4 = false;
        }
        actionBarOverlayLayout.setHasNonEmbeddedTabs(z4);
    }

    void ॱॱ() {
        if (this.ॱॱ != null) {
            this.ॱॱ.ˎ(this.ʻ);
            this.ʻ = null;
            this.ॱॱ = null;
        }
    }

    public void ˊ(int i) {
        this.ˍ = i;
    }

    public void ˎ(boolean z) {
        this.ˋˋ = z;
        if (!z && this.ͺ != null) {
            this.ͺ.ˏ();
        }
    }

    public void ˋ(boolean z) {
        if (z != this.ˋˊ) {
            this.ˋˊ = z;
            int size = this.ˊᐝ.size();
            for (int i = 0; i < size; i++) {
                ((c) this.ˊᐝ.get(i)).ˎ(z);
            }
        }
    }

    public void ᐝ(boolean z) {
        ˎ(z ? 4 : 0, 4);
    }

    public void ˊ(boolean z) {
        this.ˊ.ॱ(z);
    }

    public void ˏ(CharSequence charSequence) {
        this.ˊ.ˋ(charSequence);
    }

    public void ˎ(int i, int i2) {
        int ˋॱ = this.ˊ.ˋॱ();
        if ((i2 & 4) != 0) {
            this.ˊˋ = true;
        }
        this.ˊ.ॱ((ˋॱ & (i2 ^ -1)) | (i & i2));
    }

    public int ʼ() {
        return this.ˊ.ॱˊ();
    }

    public int ˎ() {
        return this.ˊ.ˋॱ();
    }

    public aw ˎ(aw.c cVar) {
        if (this.ʼ != null) {
            this.ʼ.ॱ();
        }
        this.ˋ.setHideOnContentScrollEnabled(false);
        this.ˎ.ˊ();
        aw bVar = new b(this, this.ˎ.getContext(), cVar);
        if (!bVar.ˊ()) {
            return null;
        }
        this.ʼ = bVar;
        bVar.ˎ();
        this.ˎ.ˊ(bVar);
        ʽ(true);
        this.ˎ.sendAccessibilityEvent(32);
        return bVar;
    }

    public void ॱॱ(boolean z) {
        this.ˊॱ = z;
    }

    private void ˊॱ() {
        if (!this.ˎˎ) {
            this.ˎˎ = true;
            if (this.ˋ != null) {
                this.ˋ.setShowingForActionMode(true);
            }
            ˊॱ(false);
        }
    }

    public void ʻ() {
        if (this.ˋॱ) {
            this.ˋॱ = false;
            ˊॱ(true);
        }
    }

    private void ͺ() {
        if (this.ˎˎ) {
            this.ˎˎ = false;
            if (this.ˋ != null) {
                this.ˋ.setShowingForActionMode(false);
            }
            ˊॱ(false);
        }
    }

    public void ˏॱ() {
        if (!this.ˋॱ) {
            this.ˋॱ = true;
            ˊॱ(true);
        }
    }

    public void ˏ(boolean z) {
        if (!z || this.ˋ.ˎ()) {
            this.ˏॱ = z;
            this.ˋ.setHideOnContentScrollEnabled(z);
            return;
        }
        throw new IllegalStateException("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
    }

    static boolean ॱ(boolean z, boolean z2, boolean z3) {
        if (z3) {
            return true;
        }
        if (z || z2) {
            return false;
        }
        return true;
    }

    private void ˊॱ(boolean z) {
        if (ॱ(this.ॱˊ, this.ˋॱ, this.ˎˎ)) {
            if (!this.ˋᐝ) {
                this.ˋᐝ = true;
                ʻ(z);
            }
        } else if (this.ˋᐝ) {
            this.ˋᐝ = false;
            ʼ(z);
        }
    }

    public void ʻ(boolean z) {
        if (this.ͺ != null) {
            this.ͺ.ˏ();
        }
        this.ˏ.setVisibility(0);
        if (this.ˍ == 0 && (this.ˋˋ || z)) {
            this.ˏ.setTranslationY(0.0f);
            float f = (float) (-this.ˏ.getHeight());
            if (z) {
                int[] iArr = new int[]{0, 0};
                this.ˏ.getLocationInWindow(iArr);
                f -= (float) iArr[1];
            }
            this.ˏ.setTranslationY(f);
            bb bbVar = new bb();
            ic ॱ = ViewCompat.ˏॱ(this.ˏ).ॱ(0.0f);
            ॱ.ॱ(this.ॱˎ);
            bbVar.ˊ(ॱ);
            if (this.ˊॱ && this.ʽ != null) {
                this.ʽ.setTranslationY(f);
                bbVar.ˊ(ViewCompat.ˏॱ(this.ʽ).ॱ(0.0f));
            }
            bbVar.ˊ(ʽॱ);
            bbVar.ˎ(250);
            bbVar.ˊ(this.ॱˋ);
            this.ͺ = bbVar;
            bbVar.ॱ();
        } else {
            this.ˏ.setAlpha(1.0f);
            this.ˏ.setTranslationY(0.0f);
            if (this.ˊॱ && this.ʽ != null) {
                this.ʽ.setTranslationY(0.0f);
            }
            this.ॱˋ.ˎ(null);
        }
        if (this.ˋ != null) {
            ViewCompat.ᐝॱ(this.ˋ);
        }
    }

    public void ʼ(boolean z) {
        if (this.ͺ != null) {
            this.ͺ.ˏ();
        }
        if (this.ˍ == 0 && (this.ˋˋ || z)) {
            this.ˏ.setAlpha(1.0f);
            this.ˏ.setTransitioning(true);
            bb bbVar = new bb();
            float f = (float) (-this.ˏ.getHeight());
            if (z) {
                int[] iArr = new int[]{0, 0};
                this.ˏ.getLocationInWindow(iArr);
                f -= (float) iArr[1];
            }
            ic ॱ = ViewCompat.ˏॱ(this.ˏ).ॱ(f);
            ॱ.ॱ(this.ॱˎ);
            bbVar.ˊ(ॱ);
            if (this.ˊॱ && this.ʽ != null) {
                bbVar.ˊ(ViewCompat.ˏॱ(this.ʽ).ॱ(f));
            }
            bbVar.ˊ(ᐝॱ);
            bbVar.ˎ(250);
            bbVar.ˊ(this.ʻॱ);
            this.ͺ = bbVar;
            bbVar.ॱ();
            return;
        }
        this.ʻॱ.ˎ(null);
    }

    public void ʽ(boolean z) {
        if (z) {
            ˊॱ();
        } else {
            ͺ();
        }
        if (ᐝॱ()) {
            ic ˏ;
            ic ˊ;
            if (z) {
                ˏ = this.ˊ.ˏ(4, 100);
                ˊ = this.ˎ.ˊ(0, 200);
            } else {
                ˊ = this.ˊ.ˏ(0, 200);
                ˏ = this.ˎ.ˊ(8, 100);
            }
            bb bbVar = new bb();
            bbVar.ˏ(ˏ, ˊ);
            bbVar.ॱ();
        } else if (z) {
            this.ˊ.ˎ(4);
            this.ˎ.setVisibility(0);
        } else {
            this.ˊ.ˎ(0);
            this.ˎ.setVisibility(8);
        }
    }

    private boolean ᐝॱ() {
        return ViewCompat.ˊᐝ(this.ˏ);
    }

    public Context ॱ() {
        if (this.ʼॱ == null) {
            TypedValue typedValue = new TypedValue();
            this.ॱ.getTheme().resolveAttribute(ah.c.ᐝ, typedValue, true);
            int i = typedValue.resourceId;
            if (i != 0) {
                this.ʼॱ = new ContextThemeWrapper(this.ॱ, i);
            } else {
                this.ʼॱ = this.ॱ;
            }
        }
        return this.ʼॱ;
    }

    public void ॱˊ() {
        if (this.ͺ != null) {
            this.ͺ.ˏ();
            this.ͺ = null;
        }
    }

    public void ˋॱ() {
    }

    public boolean ᐝ() {
        if (this.ˊ == null || !this.ˊ.ॱ()) {
            return false;
        }
        this.ˊ.ˊ();
        return true;
    }

    public void ॱ(boolean z) {
        if (!this.ˊˋ) {
            ᐝ(z);
        }
    }

    public boolean ˊ(int i, KeyEvent keyEvent) {
        if (this.ʼ == null) {
            return false;
        }
        Menu ˏ = this.ʼ.ˏ();
        if (ˏ == null) {
            return false;
        }
        boolean z;
        if (KeyCharacterMap.load(keyEvent != null ? keyEvent.getDeviceId() : -1).getKeyboardType() != 1) {
            z = true;
        } else {
            z = false;
        }
        ˏ.setQwertyMode(z);
        return ˏ.performShortcut(i, keyEvent, 0);
    }
}
